<?php
/**
 * Created by PhpStorm.
 * User: dumbledore
 * Date: 2018/3/27
 * Time: 下午3:45
 */
?>
<!DOCTYPE html>
<html>
<head>
    <!--[if lt IE 7]>
    <div class="ie6_error">还在用<strong>漏洞百出的IE6浏览器</strong>么？为了您的网络安全，请升级浏览器 <a target="_blank"
                                                                               href="http://browsehappy.com">立即升级</a>
    </div>
<![endif]-->

<meta charset="utf-8">
<title>新建管理账号-成本中心-文具1号</title>
<meta name="description"
content="文具1号作为上海办公用品供货商公司,专为世界500强企业及SOHO办公族提供网上商城一站式办公耗材批发及采购服务,一站式选购办公日用文具用品,厂家直销,好货又便宜【阳光采购就上文具1号 阳光价格 老板放心 品质保障 员工省力】"/>
<meta name="keywords" content="办公用品,办公文具,办公文具网站,文具网站,办公用品网,文具采购网,金万年"/>
<meta name="copyright" content="上海易推信息科技有限公司"/>
<meta name="renderer" content="webkit">
<base href="<?php echo base_url(); ?>"/>
<link rel="shortcut icon" href="favicon.ico"/>
<link rel="stylesheet" href="public/js/layui/css/layui.css">
<link rel="stylesheet" type="text/css" href="public/css/base.css"/>
<link rel="stylesheet" type="text/css" href="public/css/common.css"/>
<link href="public/css/city-picker.css" rel="stylesheet">
<link rel="stylesheet" type="text/css" href="public/css/index.css?v=111111"/>
    <!--[if lte IE 9]>
    <script type="text/javascript" src="public/js/html5shiv-printshiv-3.js"></script>
<![endif]-->
</head>
<body>
    <div class="bg bg-fff">
        <!--common - head -->
        <?php $this->load->view('common/header.php'); ?>
        <!--common - head end-->

        <div class="container">
            <div class="workbench-container">
                <div class="workbench-detail-container">
                    <p class="path-tit">
                        <a href="<?php echo base_url()?>cost_center/cost_center_index" class="color-red">成本中心</a>＞新建管理账号
                    </p>

                    <div class="workbench-detail-box-wrapper">
                        <form class="layui-form workbench-detail-form" method="post">
                            <div class="workbench-detail-box  workbench-detail-box-jbzl mb0">
                                <p class="workbench-detail-tit">
                                    基本信息 <span class="notice">（带 <em class="color-red">*</em>为必填项）</span>
                                </p>
                                <div class="workbench-detail-cont">
                                    <div class="apply-payment-box">
                                        <div class="layui-form-item">
                                            <label class="layui-form-label">成本中心 <em class="color-red">*</em></label>
                                            <div class="layui-input-block row">
                                                <select name="cost_center_id" lay-verify="cost_center_id">
                                                    <option value="">请选择成本中心</option>
                                                    <?php foreach ($cost_center_list as $item): ?>
                                                        <option value="<?php echo $item['id']; ?>"><?php echo $item['name']; ?></option>
                                                    <?php endforeach; ?>
                                                </select>
                                            </div>
                                            <a href="cost_center/create_cost_center_index" target="_blank" class="create-cost-center-btn">+
                                            新建成本中心</a>
                                        </div><!--成本中心-->

                                        <div class="layui-form-item">
                                            <label class="layui-form-label">账号 <em class="color-red">*</em></label>
                                            <div class="layui-input-block row" style="position: relative">
                                                <input type="text" id="jsNameInput" name="username" lay-verify="username|required" autocomplete="off" placeholder="请输入中文、字母、数字,-,_组合，4-20个字符" class="layui-input">
                                                <a href="javascript:void(0);" id="account-prefix" class="account-prefix"><?php echo $admin_info['prefix']; ?></a>
                                                <input type="hidden" name="u_prefix" value="<?php echo $admin_info['prefix']; ?>">
                                            </div>

                                            <?php if ($prefix): ?>
                                                <a href="javascript:;" onclick="change_prefix_page()" class="create-cost-center-btn">修改账号前缀</a>
                                            <?php endif; ?>
                                        </div><!--账号-->
                                        <div class="layui-form-item">
                                            <label class="layui-form-label">密码 <em class="color-red">*</em></label>
                                            <div class="layui-input-block">
                                                <input type="password" name="password" id="L_pass" lay-verify="pass|required" autocomplete="off" placeholder="建议使用字母、数字和符号两种及以上的组合，6-20个字符" class="layui-input">
                                            </div>
                                        </div><!--密码-->
                                        <div class="layui-form-item">
                                            <label class="layui-form-label">确认密码 <em class="color-red">*</em></label>
                                            <div class="layui-input-block">
                                                <input type="password" name="repassword" lay-verify="repass|required" autocomplete="off" placeholder="请再次输入密码" class="layui-input">
                                            </div>
                                        </div><!--密码-->
                                        <div class="layui-form-item">
                                            <label class="layui-form-label">联系人 <em class="color-red">*</em></label>
                                            <div class="layui-input-block">
                                                <input type="text" name="name" lay-verify="name|required" autocomplete="off"
                                                placeholder="请输入联系人" class="layui-input">
                                            </div>
                                        </div><!--联系人-->
                                        <div class="layui-form-item">
                                            <label class="layui-form-label">手机号码 <em class="color-red">*</em></label>
                                            <div class="layui-input-block">
                                                <input type="tel" name="tel" lay-verify="phone|required" autocomplete="off"
                                                id="tel_1"  placeholder="建议使用常用手机" class="layui-input">
                                            </div>
                                        </div><!--联系方式-->
                                        <div class="layui-form-item">
                                            <label class="layui-form-label">电子邮箱 <em class="color-red">*</em></label>
                                            <div class="layui-input-block">
                                                <input type="email" name="email" id="email_1" lay-verify="email|required" autocomplete="off" placeholder="建议使用常用邮箱" class="layui-input">
                                            </div>
                                        </div><!--联系方式-->

                                    </div>

                                </div>
                            </div>

                            <div class="workbench-detail-box workbench-detail-box-jbzl" style="height: auto">
                                <p class="workbench-detail-tit">
                                    预算设置 <span class="notice">（预算周期为自然月，如无预算限定可不填）</span>
                                </p>
                                <div class="workbench-detail-cont workbench-detail-1">
                                    <div class="create-management-account-wrapper">
                                        <div class="management-account-item">
                                            <p class="tit color-red">额度预算</p>
                                            <p class="name">每月额度</p>
                                            <div class="input-management-account-box">
                                                <input type="text" name="total_quota" value="" lay-verify="n_number1" class="input-management-account" placeholder="请输入金额">
                                                <span class="unit">元</span>
                                            </div>
                                        </div>
                                        <div class="management-account-item">
                                            <p class="tit">单品额度</p>
                                            <p class="name">可设置单品购买最高额度</p>
                                            <div class="input-management-account-box">
                                                <input type="text" name="single_quota" value="" lay-verify="n_number2" class="input-management-account"
                                                placeholder="请输入金额">
                                                <span class="unit">元</span>
                                            </div>
                                        </div>
                                        <div class="management-account-item">
                                            <p class="tit color-red">指定商品</p>
                                            <div class="table-box">
                                                <p class="table-row">
                                                    <span class="name">清单名称</span>
                                                    <span class="num">商品数</span>
                                                </p>
                                                <div id="list-div" style="overflow-y: scroll;height: 100px;">
                                                    <?php foreach ($centerlist as $list): ?>
                                                        <?php foreach ($centerlist as $list): ?>
                                                            <p class="table-row" data="<?php echo $list['id'] ?>">
                                                                <input type="hidden" name="list_ids[]"
                                                                value="<?php echo $list['id'] ?>"/>
                                                                <span class="table-row-name">  <?php echo $list['name'] ?></span>
                                                                <span class="table-row-num"><?php echo $list['total_num'] ?></span>

                                                                <a href="javascript:;" class="table-row-delete">删除</a>
                                                            </p>
                                                        <?php endforeach; ?>
                                                    <?php endforeach; ?>
                                                </div>
                                            </div>
                                            <a href="javascript:;" class="btn-add-list">+ 添加清单</a>
                                            <span class="cont-num">共计：<label id="l-count"><?php echo count($centerlist) ?></label>个清单
<!--                                                <label id="p-count">--><?php //echo array_sum($centertotal) ?><!--</label>件商品</span>-->
                                        </div>
                                    </div>
                                </div>
                            </div>

                            <div class="workbench-detail-box workbench-detail-box2 workbench-detail-box-jbzl" id="address-workbench-detail-cont">
                                <div id="address-detail-cont">
                                    <p class="workbench-detail-tit">
                                        收货地址 <span class="notice">（选填）</span>
                                    </p>
                                    <div class="workbench-detail-cont pb0">
                                        <div class="management-account-address-wrapper">
                                            <div class="all-address-list-display">
                                                <?php if ($manager_address_list): ?>

                                                    <?php foreach ($manager_address_list as $item): ?>
                                                        <div class="management-account-address-item">
                                                            <input type="hidden" name="address_name[]" value="<?php echo $item['name']; ?>" class="address_name">
                                                            <input type="hidden" name="address_province[]" value="<?php echo $item['province']; ?>" class="address_province">
                                                            <input type="hidden" name="address_city[]" value="<?php echo $item['city']; ?>" class="address_city">
                                                            <input type="hidden" name="address_district[]" value="<?php echo $item['district']; ?>" class="address_district">
                                                            <input type="hidden" name="address_address[]" value="<?php echo $item['address']; ?>" class="address_address">
                                                            <input type="hidden" name="address_code[]" value="<?php echo $item['postcode']; ?>" class="address_code">
                                                            <input type="hidden" name="address_telphone[]" value="<?php echo $item['phone']; ?>" class="address_telphone">
                                                            <input type="hidden" name="address_phone[]" value="<?php echo $item['tel']; ?>" class="address_phone">
                                                            <input type="hidden" name="address_default[]" value="<?php echo $item['is_default']; ?>" class="address_default">
                                                            <input type="hidden" name="region_id[]" value="<?php echo $item['region_id']; ?>" class="region_id">
                                                            <p class="tit-box">
                                                                <span class="name" title="<?php echo $item['name']; ?>"><?php echo mb_substr($item['name'], 0 , 3,"utf-8"); ?>...</span>
                                                                <span class="phone"><?php echo $item['phone']; ?></span>
                                                            </p>
                                                            <p class="address">
                                                                <?php echo $item['province']; ?> <?php echo $item['city']; ?> <?php echo $item['district']; ?>
                                                                <br>
                                                                <span class="address-detail" title="<?php echo $item['address']; ?>"><?php echo mb_substr($item['address'], 0 , 20,"utf-8"); ?></span>
                                                            </p>
                                                            <a href="javascript:;"
                                                            class="set-default default-address <?php if ($item['is_default'] == 1): ?> default <?php endif; ?>" val="<?php echo $item['id'] ?>">默认地址</a>
                                                            <a href="javascript:;" style="margin-right: 40px;" class="edit delAddress">删除</a>
                                                            <a href="javascript:;" class="edit updateAddress">修改</a>
                                                        </div>
                                                    <?php endforeach; ?>

                                                <?php endif; ?>
                                            </div>
                                            <a href="javascript:;" class="management-account-add-address-item" id="add_address_info">
                                                <span class="icon bg-icon_add_big_grey"></span>
                                                <p class="add-address-p">
                                                    新增收货地址
                                                </p>
                                            </a>
                                        </div>
                                    </div>
                                </div>
                            </div>

                            <div class="workbench-detail-box workbench-detail-box2 workbench-detail-box-jbzl" id="invoice-workbench-detail-cont">
                                <div id="invoice-detail-cont">
                                    <p class="workbench-detail-tit">
                                        发票抬头 <span class="notice">（选填）</span>
                                    </p>
                                    <div class="workbench-detail-cont">
                                        <div class="management-account-invoice-wrapper">
                                            <div class="all-invoice-list-display">
                                                <?php if($manager_invoice_list):?>
                                                    <?php foreach($manager_invoice_list as $value):?>
                                                        <div class="management-account-invoice-item">
                                                            <input type="hidden" name="invoice_type[]" value="<?php echo $value['invoice_type']; ?>" class="invoice_type">
                                                            <input type="hidden" name="invoice_company_name[]" value="<?php echo $value['invoice_company_name']; ?>" class="invoice_company_name">
                                                            <input type="hidden" name="invoice_code[]" value="<?php echo $value['invoice_code']; ?>" class="invoice_code">
                                                            <input type="hidden" name="invoice_address[]" value="<?php echo $value['invoice_address']; ?>" class="invoice_address">
                                                            <input type="hidden" name="invoice_tel[]" value="<?php echo $value['invoice_tel']; ?>" class="invoice_tel">
                                                            <input type="hidden" name="invoice_bank[]" value="<?php echo $value['invoice_bank']; ?>" class="invoice_bank">
                                                            <input type="hidden" name="invoice_account[]" value="<?php echo $value['invoice_account']; ?>" class="invoice_account">
                                                            <input type="hidden" name="invoice_default[]" value="<?php echo $value['is_default']; ?>" class="invoice_default">

                                                            <p class="company" title="<?=$value['invoice_company_name']?>">
                                                                <?=mb_substr($value['invoice_company_name'], 0,20)?>
                                                            </p>
                                                            <a href="javascript:;" class="set-default <?php if($value['is_default'] == 1):?>default<?php endif;?> default-look-up" val="<?=$value['id']?>">默认抬头</a>
                                                            <a href="javascript:;" style="margin-right: 40px;" class="edit delInvoice">删除</a>
                                                            <a href="javascript:;" class="edit updateInvoice">修改</a>
                                                        </div>

                                                    <?php endforeach;?>
                                                <?php endif;?>
                                            </div>
                                            <a href="javascript:;" id="add_invoice_info"
                                            class="management-account-add-invoice-item">
                                            <span class="icon bg-icon_add_big_grey"></span>
                                            <p class="add-address-p">
                                                新增发票
                                            </p>
                                        </a>
                                    </div>
                                </div>   <!--审核资料-->
                            </div>
                        </div>
                        <input type="hidden" value="<?php echo $customer_id; ?>" name="parent_id" id="parent_id">
                        <input type="hidden" value="2" name="identity" id="identity">
                        <button class="layui-btn btn-add" lay-submit lay-filter="*">立即添加</button>
                    </form>
                </div>
            </div>

        </div>

    </div>

    <?php $this->load->view('common/bottom.php'); ?>
</div>
<div class="mask none"></div>
<!--隐藏 添加 class  none-->
<div id="add_address_div" class="pop pop-add-address none" style="width: 675px;>
<a href="javascript:;" class="close bg-btn_close_grey_n"></a>
<p class="tit">新增地址</p>
<div class="cont">
    <form class="layui-form pop-add-address-form workbench-detail-form" id="add_address_form">
        <div class="pop-add-address-box">
            <div class="layui-form-item">
                <label class="layui-form-label">收货人姓名 <em class="color-red">*</em></label>
                <div class="layui-input-block">
                    <input type="text" id="name" name="name" lay-verify="required"
                    autocomplete="off" style="float:left;" placeholder="请输入姓名"
                    class="layui-input">
                </div>
            </div><!--账号-->

            <div class="layui-form-item">
                <label class="layui-form-label">所 在 地 区<em class="color-red">*</em></label>
                <div class="layui-input-block">
                    <div class="city-box">
                        <div id="distpicker1">
                            <div class="form-group">
                                <div style="position: relative;">
                                    <input id="city-picker1" class="form-control" readonly
                                    type="text" value="请选择省/市/区"
                                    data-toggle="city-picker" size="70">
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div><!--企业所在地-->
            <div class="layui-form-item">
                <label class="layui-form-label">街 道 地 址<em class="color-red">*</em></label>
                <div class="layui-input-block">
                    <input type="text" name="address" id="address" required
                    lay-verify="required"
                    placeholder="请输入详细地址" style="width:434px" autocomplete="off"
                    class=" layui-input">
                </div>
            </div><!--街 道 地 址-->
            <div class="layui-form-item">
                <label class="layui-form-label">邮 政 编 码</label>
                <div class="layui-input-block">
                    <input type="tel" name="postcode" id="postcode" lay-verify="name"
                    autocomplete="off" placeholder="请填写6位邮政编码" class="layui-input">
                </div>
            </div><!--密码-->

            <div class="layui-form-item">
                <label class="layui-form-label">手 机 号 码 <em class="color-red">*</em></label>
                <div class="layui-input-block">
                    <input type="tel" name="phone" id="phone" lay-verify="required" autocomplete="off" placeholder="请输入联系方式" class="layui-input">
                </div>
            </div><!--联系方式-->
            <div class="layui-form-item">
                <label class="layui-form-label">电 话 号 码 </label>
                <div class="layui-input-block">
                    <input type="text" name="tel" id="tel" autocomplete="off" placeholder="请输入区号-电话号码-区号" class="layui-input">
                </div>
            </div><!--联系方式-->
        </div>
        <div class="checkbox-box">
            <input type="checkbox" name="is_address_default" id="is_address_default" lay-skin="primary" title="设置为默认收货地址" checked="">
        </div>
        <div class="btn-box">
            <input type="hidden" value="" name="address_id" id="address_id">
            <a href="javascript:;" class="btn-submit" onclick="change_param()">保存</a>
            <a href="javascript:;" class="btn-cancel address-cancel">取消</a>
        </div>

    </form>
</div>
</div><!--新增地址-->
<div id="add_invoice_div" class="pop pop-add-address none">
    <a href="javascript:;" class="close bg-btn_close_grey_n"></a>
    <p class="tit">发票抬头</p>
    <div class="cont">
        <form class="layui-form  pop-add-address-form workbench-detail-form" action="" id="add_invoice_form">
            <div class="radio-box">
                <input type="radio" name="type" id="type1" value="2" title="增值税专用发票信息" checked="" lay-filter="type">
                <input type="radio" name="type" id="type2" value="4" title="增值税普通发票信息" lay-filter="type">
            </div>
            <div class="pop-add-address-box">
                <div class="layui-form-item">
                    <label class="layui-form-label">单 位 名 称 <em class="color-red">*</em></label>
                    <div class="layui-input-block">
                        <input type="text" name="title" lay-verify="title" id="title" autocomplete="off"
                        style="float:left;" placeholder="请输入详细的单位名称" class="layui-input">
                    </div>
                </div><!--账号-->

                <div class="layui-form-item">
                    <label class="layui-form-label">纳税人识别码<em class="color-red">*</em></label>
                    <div class="layui-input-block">
                        <input type="text" name="qycode" required id="qycode" placeholder="请输入纳税人识别码"
                        style="width:434px" autocomplete="off" class=" layui-input">
                    </div>
                </div><!--纳税人识别码-->
                <div class="layui-form-item">
                    <label class="layui-form-label">注 册 地 址<em class="color-red">*</em></label>
                    <div class="layui-input-block">
                        <input type="tel" name="invoice_address" lay-verify="invoice_address" autocomplete="off"
                        placeholder="请输入详细地址" style="width:434px" class="layui-input">
                    </div>
                </div><!--地  址-->

                <div class="layui-form-item">
                    <label class="layui-form-label">注 册 电 话<em class="color-red">*</em></label>
                    <div class="layui-input-block">
                        <input type="tel" name="invoice_tel" lay-verify="invoice_tel" autocomplete="off"
                        placeholder="请输入注册电话" class="layui-input">
                    </div>
                </div><!--联系方式-->
                <div class="layui-form-item">
                    <label class="layui-form-label">开 户 银 行<em class="color-red">*</em></label>
                    <div class="layui-input-block">
                        <input type="text" name="bank" lay-verify="bank" autocomplete="off"
                        placeholder="请输入开户银行名称" class="layui-input">
                    </div>
                </div><!--开  户  银  行-->
                <div class="layui-form-item">
                    <label class="layui-form-label">银 行 账 户<em class="color-red">*</em></label>
                    <div class="layui-input-block">
                        <input type="tel" name="card" lay-verify="card" autocomplete="off"
                        placeholder="请输入银行账户" style="width:434px" class="layui-input">
                    </div>
                </div><!--银  行  账  户-->
                <input type="hidden" name="invoice_id" id="invoice_id">
            </div>
            <div class="checkbox-box">
                <input type="checkbox" name="is_invoice_default" id="is_invoice_default" lay-skin="primary" title="设置为默认发票抬头">
            </div>


            <div class="btn-box">
                <a href="javascript:;" class="btn-submit" onclick="invoice_param()">保存</a>
                <a href="javascript:;" class="btn-cancel invoice-cancel">取消</a>
            </div>

        </form>
    </div>
</div><!--新增发票抬头-->

<div class="pop pop-account-change-msg bg-padding-inside notice-mamager-user none" style="height: 283px">
    <a href="javascript:;" class="close bg-btn_close_n"></a>
    <p class="top-tit">
        <span class="bg-logo_popup"></span>
    </p>
    <div class="cont">
        <p class="intro">
            账期用户对成本中心的信息变更将提交至平台存留依据<br>
            通知您的下级账户
        </p>
        <form class="layui-form workbench-detail-form" action="">
            <div class="layui-form-item">
                <p class="p01">请选择通知方式：</p>
                <div class="layui-input-block apply-payment-radio-box" style="margin-left:0;">
                    <input type="radio" name="notice" value="1" title="邮件通知" checked>
                    <input type="radio" name="notice" value="2" title="短信通知">
                </div>
            </div><!--请选择通知方式-->
        </form>
        <div class="btn-box">
            <a href="javascript:;" class="btn-cancel notice-cancel">取消</a>
            <a href="javascript:;" class="btn-submit notice-info">确定</a>
        </div>
    </div>
</div>  <!--请选择通知方式-->


<?php if (empty($center)): ?>
    <div class="pop pop-add-list bg-padding-inside none addrcost" style="height: 454px">
        <a href="javascript:;" class="close bg-btn_close_n"></a>
        <p class="top-tit">
            <span class="bg-logo_popup"></span>
            <span class="top-tit-text">添加清单</span>
        </p>
        <div class="cont pop-add-list-cont">
            <span class="icon-none bg-img_nonedate"></span>
            <p class="icon-none-p">没有数据</p>
            <a target="_blank" href="<?php echo $this->config->item("shop_url")?>mMPur-mylist.html" class="adjustment-budget-submit" style="float: none;">+ 新建清单</a>
        </div>
    </div>
    <?php else: ?>
        <input type="hidden" name="name" value="" id="name">
        <input type="hidden" name="id" value="" id="list_id">
        <div class="pop pop-add-list bg-padding-inside none addrcost" style="height: 454px">
            <a href="javascript:;" class="close bg-btn_close_n"></a>
            <p class="top-tit">
                <span class="bg-logo_popup"></span>
                <span class="top-tit-text">添加清单</span>
            </p>
            <div class="cont pop-add-list-cont">
                <p class="pop-add-list-row pop-add-list-row-line" style="padding-left:50px;">
                    <!--<span class="checkbox bg-btn_select_xieyi_h"></span>-->
                    <span class="name">清单名称（<?php echo count($center) ?>）</span>
                    <span class="num">商品总数</span>
                    <span class="money">金额</span>
                </p>
                <div class="pop-add-list-table">
                    <?php foreach ($center as $cen): ?>
                        <p class="pop-add-list-row" id="<?php echo $cen['id'] ?>">
                            <span class="checkbox <?php if (in_array($cen['id'], $costlist)): ?> checkbox-checked <?php endif; ?> "></span>
                            <span class="name"><?php echo $cen['name'] ?></span>
                            <span class="num"><?php echo $cen['total_num'] ? $cen['total_num'] : 0 ?></span>
                            <span class="money">￥<span class="money1"><?php echo $cen['amount'] ?></span></span>
                        </p>
                    <?php endforeach; ?>
                </div>
                <span class="add-list-max">
                    已选择：<lable id="lists_count"><?php echo count($costlist) ?></lable>个清单
<!--                    共计<lable-->
<!--                    id="lists_product_count">--><?php //echo array_sum($centertotal) ?><!--</lable> 件商品  合计 <em-->
<!--                    class="color-red"><lable id="lists_money">--><?php //echo $amount ?><!--</lable>元</em>-->
                <?php if($customer_info['identity']==1):?>
                <a style="margin-left: 200px;font-size: 12px;" class="add-list" target="_blank" href="<?php echo $this->config->item("shop_url") ?>mMPur-mylist.html">添加清单</a>
                <?php endif;?>
                </span>
                <button class="adjustment-budget-submit" >确    认</button>
                <style type="text/css">.adjustment-budget-submit:hover{color:#ffffff;}</style>
            </div>
        </div>
    <?php endif; ?>


    <script type="text/javascript" src="public/js/jquery.min.js"></script>
    <script src="public/js/layui/layui.all.js"></script>
    <script src="public/js/city-picker.data.js"></script>
    <script src="public/js/city-picker.js"></script>
    <script type="text/javascript" src="public/js/index.js"></script>
    <script>
        (function(){
            var _name_width = $('#account-prefix').width() + 13;
            $('#jsNameInput').css('text-indent', _name_width);
        })();
        layui.use(['form', 'layedit', 'laydate', 'upload'], function () {
            var form = layui.form
            , layer = layui.layer
            , layedit = layui.layedit;
            var $ = layui.jquery
            , upload = layui.upload;
            var is_account = "<?=$is_account?>";
            form.verify({
                cost_center_id: function (value, item) {
                    if(value==""){
                        $("html, body").animate({
                            scrollTop: "0px"
                        }, {
                            duration: 0,
                            easing: "swing"
                        });
                        return '请选择成本中心';
                    }
                },
            username: function (value, item) { //value：表单的值、item：表单的DOM对象
                if (value=="") {
                    return '账号不可为空';
                }
                if (value.length<4 || value.length>20) {
                    return '请输入4-20个字符';
                }
                if (!/^[\u4E00-\u9FA5A-Za-z0-9_-]+$/.test(value)) {
                    return '请输入中文、字母、数字,"-","_"组合';
                }
            }
            , name: function (value, item) { //value：表单的值、item：表单的DOM对象
                if (value=="") {
                    return '联系人不可为空';
                }
                if (value.length<2 || value.length>10) {
                    return '请输入2-10个字符';
                }
            }
            , n_number1: function (value, item) { //value：表单的值、item：表单的DOM对象
                if (value && isNaN(value)) {
                    return '每月额度只能填写数字';
                }
                if (value < 0) {
                    return '每月额度必需大于0';
                }
                if (value > 100000) {
                    return '每月额度必需小于100000';
                }
            }
            , n_number2: function (value, item) { //value：表单的值、item：表单的DOM对象
                if (value && isNaN(value)) {
                    return '单品额度只能填写数字';
                }
                if (value < 0) {
                    return '单品额度必需大于0';
                }
                if (value > 100000) {
                    return '单品额度必需小于100000';
                }
            }
            , phone: function(value, item){
                if (value=="") {
                    return '手机号码不可为空';
                }
                if (!/^1[345789]{1}\d{9}$/.test(value)) {
                    return '输入的手机格式错误';
                }
            }
            , email: function(value, item){
                if (value=="") {
                    return '邮箱地址不可为空';
                }
                if (!/^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/.test(value)) {
                    return '输入的邮箱地址格式错误';
                }
            }
            , pass: function(value, item){
                if (value.length<6 || value.length>20) {
                    return '请输入6-20个字符';
                }
                var arr = new Array();  
                arr = value.split(" ");  
                if(arr.length != 1){  
                    return '密码只能是字母，数字，常用符号的组合';
                }
            }
            ,  repass: function (value, item) { //value：表单的值、item：表单的DOM对象
                var repassvalue = $('#L_pass').val();
                if(value != repassvalue){
                    return '两次输入的密码不一致!';
                }
            }
        });

            form.on('radio(type)', function(data){
              if(data.value == 4){
                $("#add_invoice_form .layui-form-item").each(function(e){  
                    if(e>1){
                        $(this).css('display','none');
                    }
                });  
            }else{
                $('#add_invoice_form .layui-form-item').css('display','block');
            }
        });
        // 监听提交
        form.on('submit(*)', function (data) {
            $.ajax({
                type: "post",
                dataType: "json",
                url: "<?php echo base_url()?>cost_center/save_manager_user",
                data: data.field,
                async: false,
                success: function (data) {
                    if (data.code == 0) {
                        if(is_account == 0) {
                            location.href = "<?php echo base_url();?>cost_center/cost_center_index"
                        }else{
                            $('.notice-mamager-user').removeClass('none');
                            $('.notice-mamager-user').show();
                            $('.mask').removeClass('none');
                            $('.mask').show();
                        }
                        // $('.notice-mamager-user').addClass('none');
                        // $('.notice-mamager-user').hide();
                        // $('.mask').addClass('none');
                        // $('.mask').hide();
                        //layer.msg("保存成功");
                        // setTimeout(function () {
                        //     location.href = "<?php echo base_url();?>cost_center/cost_center_index"
                        // }, 2000)
                    } else {

                        if(data.msg =="该手机号已被注册"){
                            var a = $('#tel_1').offset().top;
                            $("html,body").animate({scrollTop: a}, 'slow');
                            layer.msg(data.msg);
                            return false;
                        }
                        if(data.msg =="该账号已被注册"){
                            var a = $('#jsNameInput').offset().top;
                            $("html,body").animate({scrollTop: a}, 'slow');
                            layer.msg(data.msg);
                            return false;
                        }
                        if(data.msg =="该电子邮箱地址已存在"){
                            var a = $('#email_1').offset().top;
                            $("html,body").animate({scrollTop: a}, 'slow');
                            layer.msg(data.msg);
                            return false;
                        }
                        if(data.msg =="由于上级账号每月额度有限制，所以此账号每月额度必须也有限制，请重新分配每月额度限制"){
                            var a = $('.workbench-detail-1').offset().top;
                            $("html,body").animate({scrollTop: a}, 'slow');
                            layer.msg(data.msg);
                            return false;
                        }
                        layer.msg(data.msg)
                    }
                }
            });

            return false; //阻止表单跳转。如果需要表单跳转，去掉这段即可。
            
        });
        

    });
</script>

<div class="pop pop-new-cost-center bg-padding-inside none" id="change_prefix"
style="height: auto;width:100%;margin: 0px;">
<div class="cont adjustment-budget-cont">
    <input type="text" id="prefix" class="create-cost-center-input" value="<?php echo $admin_info['prefix']; ?>"
    placeholder="请输入新前缀">
    <p class="intro">*建议输入4位以内字母和数字</p>
    <button class="adjustment-budget-submit" onclick="change_prefix()">确认</button>
</div>
</div>

<script>
    $(function(){
        $('.notice-cancel').click(function () {
            $('.notice-mamager-user').addClass('none');
            $('.notice-mamager-user').hide();
            $('.mask').addClass('none');
            $('.mask').hide();
        })
        $('.notice-info').unbind('click').click(function () {
            var type = $('input[name=notice]:checked').val();
            $.ajax({
                type: "post",
                dataType: "json",
                url: "<?php echo base_url()?>cost_center/send_email_phone",
                data: {type:type},
                async: false,
                success: function (data) {
                    if (data.code == 0) {
                        $('.notice-mamager-user').addClass('none');
                        $('.notice-mamager-user').hide();
                        $('.mask').addClass('none');
                        $('.mask').hide();
                        layer.msg("保存成功");
                        setTimeout(function () {
                            location.href = "<?php echo base_url();?>cost_center/cost_center_index"
                        }, 2000)
                    } else {
                        layer.alert(data.msg)
                    }
                }
            });
        })
    })
    function change_prefix_page() {
        layer.open({
            type: 1,
            title: '修改前缀',
            skin: 'layui-layer-rim', //加上边框
            content: $('#change_prefix'),
            // area: ['466px', '329px'], //宽高
            //content: '<input type="text" value="" name="prefix" id="prefix" placeholder="暂时没有UI"><br><button onclick="change_prefix()">确认</button>'
        });
    }

    function change_prefix() {
        var prefix = $("#prefix").val();
        $.ajax({
            type: "post",
            dataType: "json",
            url: "cost_center/change_prefix",
            data: {'prefix': prefix},
            async: true,
            success: function (data) {
                if (data.code == 0) {
                    layer.alert("保存成功");
                    $('#account-prefix').html(prefix)
                    setTimeout(function(){
                        layer.closeAll();
                    },1000)
                } else {
                    layer.alert(data.msg)
                }
            }
        });
    }

    $('#add_address_info').click(function(){
        $('.mask').removeClass('none')
        $(".mask").show();
        $("#add_address_form")[0].reset();
        $("#address_id").val('');
        $("#city-picker1").citypicker("reset");
        $("#add_address_div").removeClass('none');
        $("#add_address_div").show();
    })
    $('#add_invoice_info').click(function(){
        $('#add_invoice_form .layui-form-item').css('display','block');
        $('.mask').removeClass('none')
        $(".mask").show();
        $("#add_invoice_form")[0].reset();
        $("#invoice_id").val('');
        $("#add_invoice_div").removeClass('none');
        $("#add_invoice_div").show();
    })

    function numCheck_address(){
        var num = $('.management-account-address-item').length;                   
        for (var i = 0; i <= num; i++) {                        
            $(".management-account-address-item .updateAddress").eq(i).attr('val',i+1);                     
        }                      
    };
    numCheck_address();
    function numCheck_invoice(){
        var num = $('.management-account-invoice-item').length;                
        for (var i = 0; i <= num; i++) {                        
            $(".management-account-invoice-item .updateInvoice").eq(i).attr('val',i+1);                     
        }                      
    };
    numCheck_invoice();
    function change_param() {
        var name = $("#name").val();
        var address_id = $('#address_id').val();
        if (name=="") {
            layer.alert("姓名不可为空", function () {
                $("#name").focus();
                layer.closeAll();
            });
            return false;
        }
        if (name.length<2 || name.length>20) {
            layer.alert("请输入2-20个字符",function(){
                $("#name").focus();
                layer.closeAll();
            });
            return false;
        }
        if (!/^[\u4E00-\u9FA5A-Za-z0-9_-]+$/.test(name)) {
            layer.alert('请输入中文、字母、数字,"-","_"组合',function(){
                $("#name").focus();
                layer.closeAll();
            });
            return false;
        }
        if (typeof($("#distpicker1 [data-count='district']").attr('data-code')) == 'undefined') {
            layer.alert("所在地区必须选择");
            return false;
        }
        var address = $("#address").val();
        if (address=="") {
            layer.alert("地址不可为空!", function () {
                $("#address").focus();
                layer.closeAll();
            });
            return false;
        }
        if(address.length < 6 || address.length > 60){
            layer.alert("地址最少要6个字，最多不能超过60个字",function(){
                $("#address").focus();
                layer.closeAll();
            });
            return false;
        }
        if(/^[0-9]+$/.test(address)){
            layer.alert("不能全为数字或字母",function(){
                $("#address").focus();
                layer.closeAll();
            });
            return false;
        }
        if(/^[a-z]+$/.test(address) || /^[A-Z]+$/.test(address)){
            layer.alert("不能全为数字或字母",function(){
                $("#address").focus();
                layer.closeAll();
            });
            return false;
        }
        var postcode = $("#postcode").val();
        if(postcode){
            if(!/^[0-9][0-9]{5}$/.test(postcode)){ 
                layer.alert("请正确填写邮政编码格式",function(){
                    $("#postcode").focus();
                    layer.closeAll();
                });  
                return false; 
            }    
        }

        var phone = $("#phone").val();
        if(phone==""){ 
            layer.alert("手机号码不可为空",function(){
                $("#phone").focus();
                layer.closeAll();
            });  
            return false; 
        } 
        if(!(/^1[34578]\d{9}$/.test(phone))){ 
            layer.alert("请正确填写手机号码格式",function(){
                $("#phone").focus();
                layer.closeAll();
            });  
            return false; 
        } 
        var tel = $("#tel").val();
        if(tel){
            if(!/^0\d{2,3}-?\d{7,8}(-\d{1,8})?$/.test(tel)){ 
                layer.alert("电话号码格式不正确",function(){
                    $("#tel").focus();
                    layer.closeAll();
                });  
                return false; 
            }    
        }
        var province = $("#distpicker1 [data-count='province']").html();
        var city = $("#distpicker1 [data-count='city']").html();
        var district = $("#distpicker1 [data-count='district']").html();
        var region_id = $("#distpicker1 [data-count='district']").attr('data-code');
        var tel = $("#tel").val();
        if($("input[name=is_address_default]").is(':checked')) {
            var is_default = 1;
        }else{
            var is_default = 0;
        }
        if(is_default==1){
            $('.management-account-address-item .default-address').removeClass('default')
            $('input[name^=address_default]').val(0);
        }
        if(!address_id){
            var html = '';
            html += '<div class="management-account-address-item">';
            html += '<input type="hidden" name="address_name[]" value="'+name.substring(0,3)+'..."" class="address_name">';
            html += '<input type="hidden" name="address_province[]" value="'+province+'" class="address_province">';
            html += '<input type="hidden" name="address_city[]" value="'+city+'" class="address_city">';
            html += '<input type="hidden" name="address_district[]" value="'+district+'" class="address_district">';
            html += '<input type="hidden" name="address_address[]" value="'+address+'" class="address_address">';
            html += '<input type="hidden" name="address_code[]" value="'+postcode+'" class="address_code">';
            html += '<input type="hidden" name="address_telphone[]" value="'+phone+'" class="address_telphone">';
            html += '<input type="hidden" name="address_phone[]" value="'+tel+'" class="address_phone">';
            html += '<input type="hidden" name="address_default[]" value="'+is_default+'" class="address_default">';
            html += '<input type="hidden" name="region_id[]" value="'+region_id+'" class="region_id">';

            html += '<p class="tit-box">';
            html += '<span class="name" title="'+name+'">' + name.substring(0,3) + '...</span>';
            html += '<span class="phone">' + phone + '</span>';
            html += '</p>';
            html += '<p class="address">';
            html += province + ' ' + city + ' ' + district + '<br>';
            html += '<span class="address-detail" title="'+address+'">' + address.substring(0,20) + '</span>';
            html += '</p>';
            if (is_default == 1) {
                html += ' <a href="javascript:;" class="set-default default-address default">默认地址</a>';
            } else {
                html += ' <a href="javascript:;" class="set-default default-address">默认地址</a>';
            }
            html += '<a href="javascript:;" style="margin-right: 40px;" class="edit delAddress">删除</a>';
            html += '<a href="javascript:;" class="edit updateAddress">修改</a>';
            html += '</div>';
            $(".all-address-list-display").append(html);
        }else{
            $('.management-account-address-item').each(function(e){
                var e = e+1;
                if(e == address_id){
                    $(this).children('.address_name').val(name);
                    $(this).children('.address_province').val(province);
                    $(this).children('.address_city').val(city);
                    $(this).children('.address_district').val(district);
                    $(this).children('.address_address').val(address);
                    $(this).children('.address_code').val(postcode);
                    $(this).children('.address_telphone').val(phone);
                    $(this).children('.address_phone').val(tel);
                    $(this).children('.address_default').val(is_default);
                    $(this).children('.region_id').val(region_id);
                    $(this).children('.tit-box').html('<span class="name" title="'+name+'">' + name.substring(0,3) + '...</span><span class="phone">' + phone + '</span>');
                    $(this).children('.address').html(province + ' ' + city + ' ' + district + '<br><span class="address-detail" title="'+address+'">' + address.substring(0,20) + '</span>');
                    if(is_default==1){
                        $(this).children('.default-address').addClass('default');
                    }
                }
            })  
        }
        $("#add_address_div").addClass('none');
        $("#add_address_div").hide();
        $(".mask").addClass('none');
        $(".mask").hide();   
        numCheck_address();
        
    }

    $(document).on('click',".updateAddress", function (event) {
        var id = $(this).attr('val')
        var name = $(this).prevAll('.address_name').val();
        var province = $(this).prevAll('.address_province').val();
        var city = $(this).prevAll('.address_city').val();
        var district = $(this).prevAll('.address_district').val();
        var address = $(this).prevAll('.address_address').val();
        var code = $(this).prevAll('.address_code').val();
        var telphone = $(this).prevAll('.address_telphone').val();
        var phone = $(this).prevAll('.address_phone').val();
        var is_default = $(this).prevAll('.address_default').val();
        
        $("#add_address_form")[0].reset();
        $("#city-picker1").citypicker();
        $("#city-picker1").citypicker("reset");
        $("#city-picker1").citypicker("destroy");
        $("#city-picker1").citypicker({
            province: province,
            city: city,
            district: district
        });
        $("#name").val(name);
        $("#address").val(address);
        $("#postcode").val(code);
        $("#phone").val(telphone);
        if(phone.length<4){
            $("#tel").val("");
        }else{
            $("#tel").val(phone);
        }
        $("#address_id").val(id);
        if (is_default == 1) {
            $("#is_default").prop("checked", true);
        } else {
            $("#is_default").prop("checked", false);
        }
        $("#add_address_div").removeClass("none")
        $("#add_address_div").show();
        $('.mask').removeClass('none')
        $(".mask").show();
    })  

    function invoice_param() {
        var invoice_id = $('#invoice_id').val();
        var title = $("#title").val();
        if (title == "") {
            layer.alert("单位名称不可为空",function(){
                $("#title").focus();
                layer.closeAll();
            });
            return false;
        }
        if (title.length<3 || title.length>60) {
            layer.alert("单位名称必须为3-60个字符",function(){
                $("#title").focus();
                layer.closeAll();
            });
            return false;
        }
        if (!/^[\u4E00-\u9FA5A-Za-z0-9_()（）-]+$/.test(title)) {
            layer.alert("单位名称格式必须是中英文，数字,-,_,（）,()的组合",function(){
                $("#title").focus();
                layer.closeAll();
            });
            return false;
        }
        var qycode = $("#qycode").val();
        if (qycode=="") {
            layer.alert("纳税人识别码不可为空！", function () {
                $("#qycode").focus();
                layer.closeAll();
            });
            return false;
        }
        if (qycode.length!=15 && qycode.length!=18 && qycode.length!=20) {
            layer.alert("纳税人识别码格式输入错误，请核对！",function(){
                $("#qycode").focus();
                layer.closeAll();
            });
            return false;
        }

        if(!(/^\w+$/.test(qycode))){ 
            layer.alert("纳税人识别码格式输入错误，请核对！",function(){
                $("#qycode").focus();
                layer.closeAll();
            });  
            return false; 
        } 
        

        var type = $("input[name=type]:checked").val();
        if(type == 2){
            var address = $("input[name=invoice_address]").val();
            if (address=="") {
                layer.alert("地址不可为空！", function () {
                    $("input[name=invoice_address]").focus();
                    layer.closeAll();
                });
                return false;
            }
            if(address.length < 6 || address.length > 60){
                layer.alert("地址最少要6个字，最多不能超过60个字",function(){
                    $("input[name=type]:checked").focus();
                    layer.closeAll();
                });
                return false;
            }
            if(/^[0-9]+$/.test(address)){
                layer.alert("地址不能全为数字或字母",function(){
                    $("input[name=type]:checked").focus();
                    layer.closeAll();
                });
                return false;
            }
            if(/^[a-z]+$/.test(address) || /^[A-Z]+$/.test(address)){
                layer.alert("地址不能全为数字或字母",function(){
                    $("input[name=type]:checked").focus();
                    layer.closeAll();
                });
                return false;
            }

            var tel = $("input[name=invoice_tel]").val();
            if(tel ==""){
                layer.alert("注册电话不可为空！",function(){
                    $("input[name=invoice_tel]").focus();
                    layer.closeAll();
                });
                return false;
            }
            if(tel.length < 11 || tel.length > 20){
                layer.alert("注册电话格式输入错误，请核对！",function(){
                    $("input[name=invoice_tel]").focus();
                    layer.closeAll();
                });
                return false;
            }
            if (!/^0\d{2,3}-?\d{7,8}(-\d{1,8})?$/.test(tel) && !/^1[345789]{1}\d{9}$/.test(tel)) {
                layer.alert("注册电话格式输入错误，请核对！",function(){
                    $("input[name=invoice_tel]").focus();
                    layer.closeAll();
                });
                return false;
            }

            var bank = $("input[name=bank]").val();
            if(bank == ""){
                layer.alert("开户银行不可为空！",function(){
                    $("input[name=bank]").focus();
                    layer.closeAll();
                });
                return false;
            }
            if(bank.length < 6 || bank.length > 30){
                layer.alert("请输入正确的银行名称",function(){
                    $("input[name=bank]").focus();
                    layer.closeAll();
                });
                return false;
            }
            if (!/^[\u4E00-\u9FA5A-Za-z()（）]+$/.test(bank)) {
                layer.alert("请输入正确的银行名称",function(){
                    $("input[name=bank]").focus();
                    layer.closeAll();
                });
                return false;
            }

            var card = $("input[name=card]").val();
            if(card == ""){
                layer.alert("银行账户不可为空！",function(){
                    $("input[name=card]").focus();
                    layer.closeAll();
                });
            }
            if(card.length < 8 || card.length > 30){
                layer.alert("银行账户格式输入错误，请核对！",function(){
                    $("input[name=card]").focus();
                    layer.closeAll();
                });
                return false;
            }
            if(!/^[0-9]*$/.test(card)){ 
                layer.alert("银行账户格式输入错误，请核对！",function(){
                    $("input[name=card]").focus();
                    layer.closeAll();
                });  
                return false; 
            } 
        }

        var card = $("input[name=card]").val();
        var address = $("input[name=invoice_address]").val();
        var tel = $("input[name=invoice_tel]").val();
        var bank = $("input[name=bank]").val();
        if($("input[name=is_invoice_default]").is(':checked')) {
            var is_default = 1;
        }else{
            var is_default = 0;
        }
        if(is_default==1){
            $('.management-account-invoice-item .default-look-up').removeClass('default')
            $('input[name^=invoice_default]').val(0);
        }
        if(!invoice_id){
            var html = '';
            html += '<div class="management-account-invoice-item">';
            html += '<input type="hidden" name="invoice_type[]" value="'+type+'"" class="invoice_type">';
            html += '<input type="hidden" name="invoice_company_name[]" value="'+title+'" class="invoice_company_name">';
            html += '<input type="hidden" name="invoice_code[]" value="'+qycode+'" class="invoice_code">';
            html += '<input type="hidden" name="invoice_address[]" value="'+address+'" class="invoice_address">';
            html += '<input type="hidden" name="invoice_tel[]" value="'+tel+'" class="invoice_tel">';
            html += '<input type="hidden" name="invoice_bank[]" value="'+bank+'" class="invoice_bank">';
            html += '<input type="hidden" name="invoice_account[]" value="'+card+'" class="invoice_account">';
            html += '<input type="hidden" name="invoice_default[]" value="'+is_default+'" class="invoice_default">';
            html += '<span class="company" title="'+title+'">'+title.substring(0,20)+'</span>';
            if (is_default == 1) {
                html += ' <a href="javascript:;" class="set-default default-look-up default">默认地址</a>';
            } else {
                html += ' <a href="javascript:;" class="set-default default-look-up">默认地址</a>';
            }
            html += '<a href="javascript:;" style="margin-right: 40px;" class="edit delInvoice">删除</a>';
            html += '<a href="javascript:;" class="edit updateInvoice">修改</a>';
            html += '</div>';
            $(".all-invoice-list-display").append(html);
        }else{
            $('.management-account-invoice-item').each(function(e){
                var e = e+1;
                if(e == invoice_id){
                    $(this).children('.invoice_type').val(type);
                    $(this).children('.invoice_company_name').val(title);
                    $(this).children('.invoice_code').val(qycode);
                    $(this).children('.invoice_address').val(address);
                    $(this).children('.invoice_tel').val(tel);
                    $(this).children('.invoice_bank').val(bank);
                    $(this).children('.invoice_account').val(card);
                    $(this).children('.invoice_default').val(is_default);

                    $(this).children('.company').html(title.substring(0,20));
                    $(this).children('.company').attr('title',title)

                    if(is_default==1){
                        $(this).children('.default-look-up').addClass('default');
                    }
                }
            }) 
        }
        

        $("#add_invoice_div").addClass('none');
        $("#add_invoice_div").hide();
        $(".mask").addClass('none');
        $(".mask").hide();
        numCheck_invoice();
    }

    //修改发票抬头
    $(document).on('click',".updateInvoice", function (event) {
        var id = $(this).attr('val')
        var type = $(this).prevAll('.invoice_type').val();
        var name = $(this).prevAll('.invoice_company_name').val();
        var code = $(this).prevAll('.invoice_code').val();
        var address = $(this).prevAll('.invoice_address').val();
        var tel = $(this).prevAll('.invoice_tel').val();
        var bank = $(this).prevAll('.invoice_bank').val();
        var account = $(this).prevAll('.invoice_account').val();
        var is_default = $(this).prevAll('.invoice_default').val();

        if(type == 4){
            $("#add_invoice_form .layui-form-item").each(function(e){  
                if(e>1){
                    $(this).css('display','none');
                }
            });  
        }else{
            $('#add_invoice_form .layui-form-item').css('display','block');
        }
        $("#add_invoice_form")[0].reset();
        $("#title").val(name);
        $("#qycode").val(code);
        $("input[name=invoice_address]").val(address);
        $("input[name=invoice_tel]").val(tel);
        $("input[name=card]").val(account);
        $("input[name=bank]").val(bank);
        $("#invoice_id").val(id);
        if (is_default == 1) {
            $("#is_invoice_default").prop("checked", true);
        } else {
            $("#is_invoice_default").prop("checked", false);
        }
        if (type == 2) {
            $("#type1").prop("checked", true);
            $("#type2").prop("checked", false);
        } else if(type == 4){
            $("#type1").prop("checked", false);
            $("#type2").prop("checked", true);
        }

        $("#add_invoice_div").removeClass("none")
        $("#add_invoice_div").show();
        $(".mask").removeClass("none")
        $(".mask").show();
    }) 
    
    //设置默认抬头
    $(document).on('click',".default-look-up", function (event) {
        $(this).addClass('default');
        $(this).parent().siblings().find('.default-look-up').removeClass('default')
        $(this).prevAll('.invoice_default').val(1)
        $(this).parent().siblings().find('.invoice_default').val(0)
    })
    
    //设置默认地址
    $(document).on('click',".default-address", function (event) {
        $(this).addClass('default');
        $(this).parent().siblings().find('.default-address').removeClass('default')
        $(this).prevAll('.address_default').val(1)
        $(this).parent().siblings().find('.address_default').val(0)
    })


    //移除地址
    $(document).on('click',".delAddress", function (event) {
        $(this).parent().remove();
        numCheck_address();
    }) 

    //移除发票
    $(document).on('click',".delInvoice", function (event) {
        $(this).parent().remove();
        numCheck_invoice();
    }) 

    $(".invoice-cancel").click(function(){
        $("#add_invoice_div").css("display","none")
        $('.mask').addClass('none')
        $('.mask').hide();
    })
    $(".address-cancel").click(function(){
        $("#add_address_div").css("display","none")
        $('.mask').addClass('none')
        $('.mask').hide();
    })
    

    $(function () {
        $('.btn-add-list').click(function (e) {
            $('.mask').removeClass('none')
            $('.mask').show();
            $('.addrcost').removeClass('none')
            $('.addrcost').show();
            e.stopPropagation();
        });
        $(".checkbox").click(function () {

            $(this).toggleClass('checkbox-checked');

            $("#lists_count").html($(".checkbox-checked ").length);
            var num = 0;
            var money = 0.00;
            $(".checkbox-checked ").each(function (i, ele) {
                num += parseInt($(ele).parent().find('.num').html());
            })
            $(".checkbox-checked ").each(function (i, ele) {
                money += parseFloat($(ele).parent().find('.money1').html());
            })
            $("#lists_product_count").html(num);
            $("#lists_money").html(money.toFixed(2));
        })


        $("body").on("click", ".table-row-delete", function () {
            var count = $("#l-count").html();
            var id = $(this).parent().attr('data');
            var good_num = $(this).prev('.table-row-num').html();
            var goods_num1 = $("#lists_product_count").html()
            var goods_num2 = $("#p-count").html()
            var good_money = $("#" + id + "").find('.money1').html();
            var goods_money = $("#lists_money").html();
            $("#" + id + "").find('.checkbox').removeClass('checkbox-checked');
            $(this).parent().remove();
            $("#l-count").html(count-1);
            $("#lists_count").html(count-1);
            $("#lists_product_count").html(goods_num1-good_num);
            $("#p-count").html(goods_num2-good_num);
            $("#lists_money").html(parseFloat(goods_money-good_money).toFixed(2));
        })

        $(".adjustment-budget-submit").click(function () {
            var name = $(".checked").children('.name').text();
            var id = $(".checked").children('.id').text();
            // var id=$(".pop-add-list-table").children('.checked').attr('name');
            // var arr=id.split(",");
            var arr = [];
            var html = '';
            $('.checkbox-checked').each(function (i, ele) {
                $(ele).parent().find('.name').html();
                $(ele).parent().find('.num').html();
                $(ele).parent().attr('id')
                html += '<p class="table-row" data="' + $(ele).parent().attr('id') + '">' +
                '<input type="hidden" name="list_ids[]" value="' + $(ele).parent().attr('id') +
                '"/> ' +
                '<span class="table-row-name">' + $(ele).parent().find('.name').html() +
                '</span> ' +
                '<span class="table-row-num">' + $(ele).parent().find('.num').html() +
                '</span> ' +
                '<a href="javascript:;" class="table-row-delete">删除</a>' +
                '</p>';
            })
            $("#list-div").html(html);
            $("#l-count").html($("#lists_count").html())
            $("#p-count").html($("#lists_product_count").html())
            $('.addrcost').addClass('none')
            $('.addrcost').hide();
            $('.mask').addClass('none')
            $('.mask').hide();
        });
    })
    ;

    </script><style type="text/css">
    .pop-add-list-cont .add-list-max {
        width: auto;
    }
</style>
</body>
</html>